<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>One To Many - Join Table</title>
</head>
<body>
  <pre class="brush: java">
//Package declaration and imports omitted for brevity
//Department.java
@Entity(name = "OtmJoinTableDepartment")
@Table(name = "otm_jointable_dept")
public class Department {
	
	private int id;
	private String name;
	private Set&lt;Employee&gt; employees =
    new HashSet&lt;Employee&gt;();
	
	public Department() {}

	public Department(String name) {
		this.name = name;
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	private void setId(int id) {
		this.id = id;
	}

	@Column(nullable = false, length = 30)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany
	@JoinTable(name = "otm_jointable_dept_emp",
		joinColumns = @JoinColumn(name = "dept_id"),
		inverseJoinColumns = @JoinColumn(name = "emp_id"))
	public Set&lt;Employee&gt; getEmployees() {
		return employees;
	}

	private void setEmployees(Set&lt;Employee&gt; employees) {
		this.employees = employees;
	}
	
	public void addEmployee(Employee employee) {
		this.getEmployees().add(employee);
	}
	
	public void removeEmployee(Employee employee) {
		this.getEmployees().remove(employee);
	}
}

////////////////////////////////////////////////////////

Employee.java source

@Entity(name = "OtmJoinTableEmployee")
@Table(name = "otm_jointable_emp")
public class Employee {

	private int id;
	private String name;
	
	public Employee() {}

	public Employee(String name) {
		this.name = name;
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	private void setId(int id) {
		this.id = id;
	}

	@Column(nullable = false, length = 30)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
  </pre>
</body>
</html>
